---
title: Ordering Feature Layers
description: Controlling the order of feature layers allows greater cartographic control over the rendering of layers beyond the normal tile / polygon / point ordering.
layout: example.hbs
---

<div id="map"></div>

<script>
  var map = L.map("map").setView([45.5384, -122.6695], 16);

  L.esri.basemapLayer("Topographic").addTo(map);

  var neighborhoodsUrl = "https://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Neighborhoods_pdx/FeatureServer/0";
  var eliotFootprintsUrl = "https://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Eliot%20Building%20Footprints/FeatureServer/0";
  var blockPointsUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/0";

  // create a map pane for neighborhoods
  map.createPane('neighborhoods');

  // Define the created pane when creating the feature layer
  L.esri.featureLayer({
    url: neighborhoodsUrl,
    pane: 'neighborhoods',
  }).addTo(map);

  // Panes are added to the map in order - this pane will be sit on top of 'neighborhoods'
  map.createPane('footprints');

  L.esri.featureLayer({
    url: eliotFootprintsUrl,
    pane: 'footprints',
    style: function (feature) {
      return {  color: 'white', weight: 0, fillOpacity: 1  };
    }
  }).addTo(map);

  map.createPane('blockpoints');

  // for point GeoJSON, Leafet expects custom panes to be returned in pointToLayer()
  L.esri.featureLayer({
    url: blockPointsUrl,
    pointToLayer: function (geojson, latlng) {
      return L.circleMarker(latlng, {
        pane: 'blockpoints',
        color: 'green'
      });
    }
  }).addTo(map);

</script>
